#include <cassert>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <unistd.h>

typedef void (*task_t) (int);

void log(int id) { std::cout << "proc["<<id<<"]["<<getpid()<<"] take log task" << std::endl; }
void sql(int id) { std::cout << "proc["<<id<<"]["<<getpid()<<"] take sql task" << std::endl; }
void net(int id) { std::cout << "proc["<<id<<"]["<<getpid()<<"] take net task" << std::endl; }

struct Task
{
    Task()
    {
        tasks.push_back(log);
        tasks.push_back(sql);
        tasks.push_back(net);
    }

    void operator()(int id, int command)
    {
        assert(command >= 0 && command < tasks.size());
        tasks[command](id);
    }

    std::vector<task_t> tasks;
};

